import { firewallRequest } from '@core/utils/request';

export interface FetchRuleDetailParams {
  firewallId: string,
  ruleId: string,
}

export interface RuleDetail {
  policyDesc: string,
  ruleName: string,
  dstIp: string,
  dstPort: string,
  srcIp: string,
  srcPort: string,
  status: string,
  appName: string,
  service: string,
  action: string,
  priority: number,
  firewallId: string,
}

export interface StatusSwitchParams {
  firewallId: string,
  ruleId: string,
  status: string,
}

export default class SecPolicy {
  static fetchOne = (params: FetchRuleDetailParams) => {
    return firewallRequest.get<
      FetchRuleDetailParams,
      RuleDetail
      >('/ctcloud/vfw/v1_system_sec_policy_info', { params });
  };

  static changeStatus = (params: StatusSwitchParams) => {
    return firewallRequest.post<
      StatusSwitchParams
      >('/ctcloud/vfw/v1_system_sec_policy_switch_protect_status', { params });
  };
}
